/*
 *
 * Customer.m
 *
 *	You may freely copy, distribute and reuse the code in this example.
 *	NeXT disclaims any warranty of any kind, expressed or implied, as to
 *	its fitness for any particular use.
 *
 */

#import "Customer.h"

@implementation Customer


// Overridden methods

- init
{
	[super init];
	// "template" values for a new customer are here
	name = NXCopyStringBuffer("Joe Customer");	 
	return self;
}

- free
{
	if(name != NULL) NX_FREE(name);
	return [super free];
}

- read:(NXTypedStream *)stream
{
	[super read:stream];
	NXReadTypes(stream, "*i", &name, &uid);
	return self;
}

- write:(NXTypedStream *)stream
{
	[super write:stream];
	NXWriteTypes(stream, "*i", &name, &uid);
	return self;
}



// Accessor methods

- setCustomerName: (const char *)newName
{
	if (name != NULL) NX_FREE(name);
	name = (newName != NULL) ? NXCopyStringBuffer(newName) : NULL;
	return self;
}

- (const char *) customerName
{
	return name;
}

- setCustomerUid: (int)newUid
{
	// XXX - should check for uniqueness here
	uid = newUid;
	return self;
}

- (int) customerUid
{
	return uid;
}


@end
